<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>图片文本</title>
</head>
<body>
<h2>图片文本</h2>
<p>在图片中间位置添加文本信息:</p>

<div class="container">
    <img src="../img/rock600x400.jpg" alt="Norway" >
    <div class="a">左上</div>
    <div class="b">左下</div>
    <div class="center">居中</div>
    <div class="c">右上</div>
    <div class="d">右下</div>
</div>
<h2>响应式卡片</h2>

<div class="polaroid f">
    <img src="../img/rock600x400.jpg" alt="Norway" >
    <div class="e">
        <p>The Troll's tongue in Hardanger, Norway</p>
    </div>
</div>

<div class="polaroid">
    <img src="../img/lights600x400.jpg" alt="Norway" >
    <div class="e">
        <p>Northern Lights in Norway</p>
    </div>
</div>
<div class="g">
    <img src="../img/pineapple.jpg"  class="h" alt="">
    <img src="../img/pineapple.jpg"  class="h" alt="">
    <img src="../img/pineapple.jpg" class="h" alt="">
    <img src="../img/pineapple.jpg" class="h" alt="">
    <img src="../img/pineapple.jpg" class="i" alt="">
    <img src="../img/pineapple.jpg" class="i" alt="">
    <img src="../img/pineapple.jpg" class="i" alt="">
    <img src="../img/pineapple.jpg" class="i" alt="">
    <img src="../img/pineapple.jpg" class="j" alt="">
    <img src="../img/pineapple.jpg" class="j" alt="">
    <img src="../img/pineapple.jpg" class="j" alt="">
    <img src="../img/pineapple.jpg" class="j" alt="">

</div>
<h2 style="text-align:center">响应式图片相册</h2>

<div class="responsive">
    <div class="img">
        <a target="_blank" href="img_fjords.jpg">
            <img src="http://www.runoob.com/wp-content/uploads/2016/04/img_fjords.jpg" alt="Trolltunga Norway">
        </a>
        <div class="desc">Add a description of the image here</div>
    </div>
</div>


<div class="responsive">
    <div class="img">
        <a target="_blank" href="img_forest.jpg">
            <img src="http://www.runoob.com/wp-content/uploads/2016/04/img_forest.jpg" alt="Forest">
        </a>
        <div class="desc">Add a description of the image here</div>
    </div>
</div>

<div class="responsive">
    <div class="img">
        <a target="_blank" href="img_lights.jpg">
            <img src="http://www.runoob.com/wp-content/uploads/2016/04/img_lights.jpg" alt="Northern Lights" >
        </a>
        <div class="desc">Add a description of the image here</div>
    </div>
</div>

<div class="responsive">
    <div class="img">
        <a target="_blank" href="img_mountains.jpg">
            <img src="http://www.runoob.com/wp-content/uploads/2016/04/img_mountains.jpg" alt="Mountains" >
        </a>
        <div class="desc">Add a description of the image here</div>
    </div>
</div>

<div class="clearfix"></div>

<div style="padding:6px;">

    <h4>重置浏览器大小查看效果</h4>
</div>

<h2>图片模态框</h2>
<p>本实例演示了如何结合 CSS 和 JavaScript 来一起渲染图片。</p><p>
    首先，我们使用 CSS 来创建 modal 窗口 (对话框), 默认是隐藏的。<p>
<p>然后，我们使用 JavaScript 来显示模态窗口，当我们点击图片时，图片会在弹出的窗口中显示：</p>
<img id="myImg" src="../img/img_lights.jpg" alt="Northern Lights, Norway" width="300" height="200">

<!-- The Modal -->
<div id="myModal" class="modal">
    <span class="close">×</span>
    <img class="modal-content" id="img01">
    <div id="caption"></div>
</div>

<style>
    .close{
        position: absolute;
        top:15px;
        right: 35px;
        color:#f1f1f1;
        font-size:40px;
        font-weight: bold;
        transition: 0.3s;
    }
    .close:hover,.close:focus{
        color: #bbb;
        text-align: center;
        cursor: pointer;
    }
    @keyframes zoom {
        from{transform: scale(0.1)}
        to{transform: scale(1)}

    }
    .modal-content ,#caption{
        animation: zoom 0.6s;
    }
    .modal-content{
        margin:auto;
        display: block;
        width: 80%;
        max-width:700px;
    }
    #caption{
        margin:auto;
        display: block;
        width: 80%;
        max-width:700px;
        text-align: center;
        color:#ccc;
        padding:10px 0;
        height: 150px;
    }
   .modal{
       display: none;
       position: fixed;
       z-index: 1;
       padding-top: 100px;
       left:0;
       top:0;
       width: 100%;
       height: 100%;
       overflow: auto;
       background-color: rgb(0,0,0); /* Fallback color */
       background-color: rgba(0,0,0,0.9); /* Black w/ opacity */

   }
    #myImg{
        cursor: pointer;
        transition: 0.3s;
    }
    #myImg:hover{
       opacity: 0.7;
    }
    .responsive .img{
        border:1px solid darkgrey  ;
        width: 100%;
        height: auto;
    }
    .responsive img:hover{
        border:  1px solid black;
    }
    .desc{
        padding: 15px;
        text-align: center;
    }

    .responsive{
        box-sizing: border-box;
        padding: 0 6px;
        float:  left;
        width: 24.9999%;

    }
    .h{
       filter: grayscale(10%);
    }
    .i{
        filter: grayscale(50%);
    }
    .j{
        filter: grayscale(100%);
    }
   .f{
       margin-top: 500px;
   }
    .container{
        position: absolute;
    }
    .container div{
        position: absolute;
        color:red
    }
    .a{
        left:0;
        top:0;
    }
    .b{
        bottom: 0;
        left:0
    }
    .center{


        top:50%;
        left:50%;
    }
    .c{
        right: 0;
        top:0;
    }
    .d{
        right: 0;
        bottom: 0;

    }
</style>
<script>
    var img = document.getElementById("myImg")
    var modal = document.getElementById("myModal")
    var modalImg = document.getElementById("img01")
    var caption = document.getElementById("caption")
    img.onclick = function () {
        modal.style.display = "block"
        modalImg.src= this.src;
        modalImg.alt = this.alt;
        caption.innerHTML = this.alt;
    }
    var close  = document.getElementsByClassName("close")[0]
    close.onclick = function () {
        modal.style.display = "none"
    }
</script>
</body>
</html>